<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="维修管理" bodyClass="white-bg" libs=["bootstrapSelect"]/>
<div class="wrapper wrapper-content ibox-content">
    <@f.form id="task-form-complete" class="form-horizontal">
    <h4 class="form-header h4"><@ctx.i18n text = "基本信息"/></h4>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "设备编号"/>：</label>
                <div class="col-sm-8">
                    <!--<input class="form-control" name="equipmentCode" value="" type="text"  >-->
                    <@f.tableselect checked=false keyId="equipmentCode" keyName="equipmentCode" url="bus/equipment/list"
                    name="equipmentCode" boxTitle="设备编码"  value="${archives.equipmentCode?default('')}"
                    labelValue="${archives.equipmentCode?default('')}"
                    tableInfo = "[{field:'equipmentName',title:'设备名称'},
                    {field:'equipmentModel',title:'设备型号'}, {field:'meteringUnit',title:'单位'},
                    {field:'useDepartment',title:'使用部门'},{field:'remark',title:'备注'}]" placeholder="请选择设备编号" />

                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "设备名称"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>

                        <input class="form-control" name="equipmentName"  value="${archives.equipmentName?default('')}" type="text" readonly >
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "设备型号"/>：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="equipmentModel" value="${archives.equipmentModel?default('')}" type="text" readonly >
                </div>
            </div>
        </div>

        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "单位"/>：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="meteringUnit" value="${archives.meteringUnit?default('')}" type="text" readonly >
                </div>
            </div>
        </div>

    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "使用说明"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <!--<span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
                        <div class="col-xs-7">
                            <input type="file" id="instructionsUrl"  style="padding-top: 4px;"/>
                            <input name="instructionsUrl" value="${archives.instructionsUrl?default('')}" hidden>
                        </div>
                        <!--<input class="form-control time-input" name="instructionsUrl"  data-type="date" data-format="yyyy-MM-dd HH:mm:ss" type="text"  required>-->
                        <!--readonly="true"-->
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "计量公司证书"/>：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <div class="col-xs-7">
                            <input type="file" id="certificateUrl"  style="padding-top: 4px;"/>
                            <input name="certificateUrl" value="" hidden>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "合格证"/>：</label>
                <div class="col-sm-8">
                    <input type="file" id="qualifiedUrl"  style="padding-top: 4px;"/>
                    <input name="qualifiedUrl" value="" hidden>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "操作规程"/>：</label>
                <div class="col-sm-8">
                    <input type="file" id="operationUrl"   style="padding-top: 4px;"/>
                    <input name="operationUrl" value="${archives.operationUrl?default('')}" hidden>
                </div>
            </div>
        </div>
    </div>

</div>

</@f.form>
<div class="hr-line-dashed"></div>
<div class="row" style="text-align: center;" id="_addTab">
    <!--<button type="button" class="btn btn-sm btn-primary" onclick="opt.form.submit()"><i class="fa fa-check"></i><@ctx.i18n text = "保存"/></button>&nbsp;-->
    <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i><@ctx.i18n text = "保存"/></button>&nbsp;
    <button type="button" class="btn btn-sm btn-danger" onclick="opt.modal.closeTab()"><i class="fa fa-reply-all"></i><@ctx.i18n text = "关闭"/></button>
</div>
</div>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "bus/archives";

    $('#tipBut button').click(function(){
        $('#comment').text($(this).text())
    });

    $("#task-form-complete").validate({
        focusCleanup: true
    });

    function tep() {
        opt.layer.open({
            type: 1,
            area: ['580px', '180px'],
            title: '<i class="fa fa-upload"></i> 选择 ',
            shade: 0.3,
            shadeClose: true,
            resize: false,
            scrollbar: true,
            content: opt.template('add1'),
        });
    }

    function tableCallback(id, event, index, layero, nodes){
        console.log("aaaaaaaaaaaaaaa")
        if(id == "equipmentCode"){
            console.log("弹出表格选择===>>>>: id:" + id + "  event:" + event + " index:" + index + "  layero:"+ layero + " nodes:" + JSON.stringify(nodes));
            console.log(nodes.table[0]);
            var data = nodes.table[0];

            $("input[name=equipmentName]").val(data.equipmentName);
            $("input[name=equipmentModel]").val(data.equipmentModel);
            $("input[name=meteringUnit]").val(data.meteringUnit);
            // $("input[name=useDepartment]").val(data.useDepartment);
            // $("input[name=remark]").val(data.remark);

        }
    }

    function submitHandler() {

        //  var arrivalAmount= parseFloat($('input[name="arrivalAmount"]').val());
        //  var claimAmount= parseFloat($('input[name="claimAmount"]').val());
        //  console.log(arrivalAmount);
        //  console.log(claimAmount);
        //  console.log(claimAmount>arrivalAmount);
        // if(claimAmount>arrivalAmount){
        //   //  alert("已认领金额不能大于到账金额");
        //   return  opt.modal.alertWarning("已认领金额不能大于到账金额");
        // }

        if (opt.validate.form()) {
            opt.operate.saveTab(prefix + "/edit", $('#task-form-complete').serialize());
        }
    }

    /*上传说明文件*/
    $("#instructionsUrl").change(function () {
        uploadFile();
    });
    function uploadFile() {
        var oFiles = document.getElementById("instructionsUrl").files;
        console.log(oFiles);
        var formdata = new FormData();
        formdata.append("file", oFiles[0]);
        console.log(formdata)
        opt.common.sendAjax({
            url: prefix + "/doUploadFile",
            data: formdata,
            type: "POST",
            processData: false,
            contentType: false,
            success: function(result) {
                $("input[name=instructionsUrl]").val(result.data);
                console.log("1111111111");
                console.log(result);
                console.log(result);
            }
        })
    }

    /*上传计量公司证书*/
    $("#certificateUrl").change(function () {
        uploadFile1();
    });
    function uploadFile1() {
        var oFiles = document.getElementById("certificateUrl").files;
        console.log(oFiles);
        var formdata = new FormData();
        formdata.append("file", oFiles[0]);
        console.log(formdata)
        opt.common.sendAjax({
            url: prefix + "/doUploadFile",
            data: formdata,
            type: "POST",
            processData: false,
            contentType: false,
            success: function(result) {
                $("input[name=certificateUrl]").val(result.data);
                console.log("1111111111");
                console.log(result);
                console.log(result);
            }
        })
    }

    /*上传合格证*/
    $("#qualifiedUrl").change(function () {
        uploadFile2();
    });
    function uploadFile2() {
        var oFiles = document.getElementById("qualifiedUrl").files;
        console.log(oFiles);
        var formdata = new FormData();
        formdata.append("file", oFiles[0]);
        console.log(formdata)
        opt.common.sendAjax({
            url: prefix + "/doUploadFile",
            data: formdata,
            type: "POST",
            processData: false,
            contentType: false,
            success: function(result) {
                $("input[name=qualifiedUrl]").val(result.data);
                console.log("1111111111");
                console.log(result);
                console.log(result);
            }
        })
    }

    /*上传操作规程*/
    $("#operationUrl").change(function () {
        uploadFile3();
    });
    function uploadFile3() {
        var oFiles = document.getElementById("operationUrl").files;
        console.log("1111");
        console.log(oFiles);
        var formdata = new FormData();
        console.log("2222");
        formdata.append("file", oFiles[0]);
        console.log("333");
        console.log(formdata)
        console.log("4444");
        opt.common.sendAjax({
            url: prefix + "/doUploadFile",
            data: formdata,
            type: "POST",
            processData: false,
            contentType: false,
            success: function(result) {
                console.log("55555");
                console.log(result.data);
                console.log(result.data);
                console.log(result);
                $("input[name=operationUrl]").val(result.data);
                console.log("1111111111");
                console.log(result);
                console.log(result);
            }
        })
    }



</script>
<!--<script id="upload" type="text/template">-->
<!--<form id="inputForm" method="post" enctype="multipart/form-data" class="form-horizontal mt20 mb10">-->
<!--<label class="control-label col-xs-5"><span class="required">*</span> 导入文件：</label>-->
<!--<div class="col-xs-7">-->
<!--<input type="file" id="f" name="f" style="padding-top: 4px;"/>-->
<!--</div>-->
<!--</form>-->

<!--</script>-->

</@footer>
</@pageTheme>